require 'login_system'

class Plugin::ThemeswitchController < ActionController::Base
  before_filter :set_site_template_root
  def set_site_template_root
    self.class.template_root = "#{RAILS_ROOT}/components/"
    @template.base_path = template_root
  end 
  include LoginSystem
  before_filter :login_required, :only => [:config]
  def show
    @plugin=Extplugin.find_by_name("themeswitch")
	@config=@plugin.config 
  	if @plugin.activated==1
  	  render(:layout => false)
  	else
  	  render :text => _("not activated")
  	end  	
  end
	
  def config
    @plugin=Extplugin.find_by_name("themeswitch")
    @config=@plugin.config 
  end
	
  def changetheme
    cookies[:theme]={:value=>params["themeswitch"],:expires=>1.year.from_now}
    if session[:currentpage]!=nil
    	redirect_to session[:currentpage]
    else
        redirect_to :controller=>"media",:action=>"list"
    end
  end
  
end